package com.trace.basic;

/**
 * Created by denglw on 2020/1/13.<br/>
 * Desc: 指令重排序
 */
public class Reorder {

    private static boolean ready = false;
    private static int number = 0;

    /**
     * 1、无限循环
     * 2、输出42
     * 3、输出0
     */
    public static void main(String[] args) {
        new Thread(() -> {
            while (!ready) { Thread.yield(); }
            System.out.println(number);
        }).start();

        ready = true;
        number = 42;
    }

}
